/*
 * BSM6.0
 *
 * Copyright 2012-2013 (C) SINODATA CO., LTD. All Rights Reserved.
 */
package com.sinodata.bsm.cicp.service;

import java.io.IOException;

import javax.management.remote.JMXConnector;

import org.apache.log4j.Logger;

import com.sinodata.bsm.cicp.util.JmxUtil;
import com.sinodata.bsm.common.vo.ProtocolParameter;

/**
 * <p>
 * Description: 
 * </p>
 *
 * @author dongyushi
 * @version 1.0

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * 2012-8-13 上午9:25:29          dongyushi        1.0         To create
 * </p>
 *
 * @since 
 * @see     
 */
public class JmxConnectionService {
    private static final Logger logger = Logger.getLogger(DBConnectionService.class);

    public Boolean testConn(ProtocolParameter protocolParameter) {
        String ip = protocolParameter.getIp();
        Integer port = protocolParameter.getPort();
        String instType = protocolParameter.getInstType();
        String username = protocolParameter.getUserName();
        String password = protocolParameter.getPwd();
        JMXConnector jmxConnector = null;
        try {
            jmxConnector = JmxUtil.initConnection(instType, ip, port, username, password);
        } catch (IOException e) {
            logger.error(e.getMessage());
        }
        if (jmxConnector != null) {
            return true;
        } else {
            return false;
        }
    }
}
